<template>
	<view><button open-type="getUserInfo" @getuserinfo="wxLogin">点我登录</button></view>
</template>

<script>
export default {
	methods: {
		wxLogin(userInfoRes) {
			// 获取用户信息
			let { encryptedData, signature, iv, rawData } = userInfoRes.detail;
			// 获取code
			uni.login({
				success: async loginRes => {
					let code = loginRes.code
					// 发请求
					let data = await this.$request({
						url:'/api/public/v1/users/wxlogin',
						method:'POST',
						data:{
							encryptedData,
							signature,
							iv,
							rawData,
							code
						}
					})
				}
			});
		}
	}
};
</script>

<style></style>
